package cn.tedu;

import java.sql.*;

public class Demo03 {
    public static void main(String[] args) throws SQLException {
        //1.创建链接对象
        String url="jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai";
        Connection conn= DriverManager.getConnection(url,"root","root");
        //2.创建执行SQL语句的对象
        Statement s=conn.createStatement();
        //3.执行SQL语句
 //       s.executeUpdate("insert into emp(name) values('tom')");
  //      s.executeUpdate("update emp set name='jerry' where name='tom'");
        s.executeUpdate("delete from emp where name='jerry'");
        ResultSet rs=s.executeQuery("select name,sal from emp");
        while(rs.next()){
            String name=rs.getString(1);
            double sal=rs.getDouble(2);
            System.out.println(name+" "+sal);
        }
        //4.关闭资源
        conn.close();
        System.out.println("执行完毕");
    }
}
